# Contributor: Leonardo Arena <rnalrd@alpinelinux.org>
# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=ospd-openvas
pkgver=21.4.4
pkgrel=2
pkgdesc="ospd-openvas is an OSP server implementation to allow GVM to remotely control an OpenVAS Scanner"
url="https://github.com/greenbone/ospd-openvas"
arch="noarch"
license="AGPL-3.0-or-later"
pkgusers="gvm"
pkggroups="gvm"
depends="py3-psutil py3-redis py3-packaging
py3-deprecated py3-defusedxml py3-lxml py3-paho-mqtt" # missing py3-gnupg in testing
makedepends="py3-build py3-installer py3-poetry-core py3-wheel"
checkdepends="py3-pytest"
subpackages="$pkgname-openrc"
install="$pkgname.post-install"
source="$pkgname-$pkgver.tar.gz::https://github.com/greenbone/ospd-openvas/archive/v$pkgver.tar.gz
	$pkgname.initd
	ospd.conf"

build() {
	# XXX: poetry hack to not ignore files
	GIT_DIR=. python3 -m build --no-isolation --wheel
}

check() {
	pytest -v
}

package() {
	python3 -m installer -d "$pkgdir" \
		dist/ospd_openvas-$pkgver-py3-none-any.whl
	install -d -o $pkgusers -g $pkggroups "$pkgdir"/run/ospd
	install -Dm755 "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
	install -Dm644 "$srcdir"/ospd.conf "$pkgdir"/etc/openvas/ospd.conf
}

sha512sums="
3981b0a9044f90243fe06f15b0d8ee5a6b1a334556f6de76955aecda0404da2f8bd1d39bf547093a31c244f0aabae819f5e45e8c518984fc7d50764a267086e9  ospd-openvas-21.4.4.tar.gz
7567dd8541fb84b8a8ef82c51c8a1e9d29f9a78483525f55f59cb29a57d42ca96499b7e3bf30e5fef0e02293ecb1455a7a748e3093b1892b2be80632f75e7e32  ospd-openvas.initd
c3714d1555dac2b557e8faa1dba7bd3d4b27930b0a18ec644f3bd4ef4e02d598eaca012651b105899d2ca192196cbbdb2eeef1d70a514222bbe2698c1874ae19  ospd.conf
"
